#ifndef _GRAPH_H_
#define _GRAPH_H_

#include <stdlib.h>
#include <stdio.h>

#include "list.h"
#include "set.h"

typedef struct adjlist {
	void *vertex;
	set_t adjacent;
}adjlist_t;


typedef struct graph {
	int 	vcount;
	int 	ecount;
	int		(*match)(const void *key1, const void *kye2);
	void 	(*destroy)(void *data);

	list_t	adjlists;
}graph_t;


typedef enum vertex_color_ {
	white, gray, black
}vertex_color_t;


void graph_init(graph_t *graph, int (*match)(const void *key1, const void *key2), void (*destroy)(void *data));
int graph_insert_vertex(graph_t *graph, const void *data);
int graph_insert_edge(graph_t *graph, const void *data1, const void *data2);
int graph_remove_vertex(graph_t *graph, void **data);
int graph_remove_edge(graph_t *graph, void *data1, void **data2);
int graph_is_adjacent(graph_t *graph, const void *data1, const void *data2);
int graph_adjlist(graph_t *graph, const void *data, adjlist_t **adjlist);
void graph_destroy(graph_t *graph);


#define graph_adlists(graph)		((graph)->adjlists)
#define graph_vcount(graph)		((graph)->vcount)
#define graph_ecount(graph)		((graph)->ecount)

#endif /*_GRAPH_H_*/

